/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MODEL;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Observable;

/**
 *
 * @author Irene & Morten
 */
public class Link extends Observable implements Serializable{

    private String title;
    private String url;
    private ArrayList<String> fun;
    private ArrayList<String> exercise;
    private ArrayList<String> work;
    private ArrayList<String> misc;

    public Link() {
        fun = new ArrayList<String>();
        exercise = new ArrayList<String>();
        work = new ArrayList<String>();
        misc = new ArrayList<String>();

    }

    /*adds funlink to the arraylist fun and notifies observer
     * @param title is the title of the link
     * @param url is the webaddress of the link
     */
    public void addFunLink(String title, String url) {
        this.title = title;
        this.url = url;
        String s = ("________________");
        fun.add(title);
        fun.add(url);
        fun.add(s);
        setChanged();
        notifyObservers();

    }

    /*adds exerciselink to the arraylist exercise and notifies observer
     * @param title is the title of the link
     * @param url is the webaddress of the link
     */
    public void addExerciseLink(String title, String url) {
        this.title = title;
        this.url = url;
        String s = ("________________");
        exercise.add(title);
        exercise.add(url);
        exercise.add(s);
        setChanged();
        notifyObservers();

    }

    /*adds worllink to the arraylist work and notifies observer
     * @param title is the title of the link
     * @param url is the webaddress of the link
     */
    public void addWorkLink(String title, String url) {
        this.title = title;
        this.url = url;
        String s = ("________________");
        work.add(title);
        work.add(url);
        work.add(s);
        setChanged();
        notifyObservers();
    }

    /*adds misclink to the arraylist misc and notifies observer
     * @param title is the title of the link
     * @param url is the webaddress of the link
     */
    public void addMiscLink(String title, String url) {
        this.title = title;
        this.url = url;
        String s = ("________________");
        misc.add(title);
        misc.add(url);
        misc.add(s);
        setChanged();
        notifyObservers();
    }

    /*Removes the funlink via url from the list
     * @param url is the list to be removed
     */
    public void removeFunLink(String url) {
        this.url = url;
        fun.remove(url);
        setChanged();
        notifyObservers();
    }

    public void removeExerciseLink(String url) {
        this.url = url;
        exercise.remove(url);
        setChanged();
        notifyObservers();
    }

    public void removeWorkLink(String url) {
        this.url = url;
        work.remove(url);
        setChanged();
        notifyObservers();
    }

    public void removeMiscLink(String url) {
        this.url = url;
        misc.remove(url);
        setChanged();
        notifyObservers();
    }

    public ArrayList<String> getExercise() {
        return exercise;
    }

    public ArrayList<String> getFun() {
        return fun;
    }

    public ArrayList<String> getMisc() {
        return misc;
    }

    public ArrayList<String> getWork() {
        return work;
    }
}
